
#include "LUAEngine.h"

namespace lua_engine
{
	void bindObjectMethods(luabridge::module & m)
	{
		m	.class_<Object>("Object")
		.method(&Object::GetGUID, "GetGUID", "getGUID", "getguid", NULL)
		.method(&Object::GetHighGUID, "GetHighGUID", "getHighGUID", "gethighguid", NULL)
		.method(&Object::GetLowGUID, "GetLowGUID", "getLowGUID", "getlowguid", NULL)
		.method(&Object::GetNewGUID, "GetNewGUID", "getNewGUID", "getnewguid", NULL)
		.method(&Object::GetEntry, "GetEntry", "getEntry", "getentry", NULL)
		.method(&Object::GetScale, "GetScale", "getScale", "getscale", NULL)
		.method(&Object::SetScale, "SetScale", "setScale", "setscale", NULL)
		//.method( &Object::GetTypeFromGUID, "GetTypeFromGUID", "getTypeFromGUID", "gettypefromguid", NULL)
		.method(&Object::GetTypeId, "GetTypeID", "getTypeID", "gettypeid", NULL)
		.method(&Object::IsUnit, "IsUnit", "isUnit", "isunit", NULL)
		.method(&Object::IsGameObject, "IsGameObject", "isGameObject", "isgameobject", NULL)
		.method(&Object::IsPlayer, "IsPlayer", "isPlayer", "isplayer", NULL)
		.method(&Object::IsItem, "IsItem", "isItem", "isitem", NULL)
		.method(&Object::IsCreature, "IsCreature", "isCreature", "iscreature", NULL)
		.method(&Object::IsPet, "IsPet", "isPet", "ispet", NULL)
		.method((bool(Object::*)(float, float, float, float, bool))&Object::SetPosition, "SetPosition", "setPosition", "setposition", NULL)
		.method(&Object::GetPositionX, "GetPositionX", "getPositionX", "getpositionx", "getX", "GetX", "getx", NULL)
		.method(&Object::GetPositionY, "GetPositionY", "getPositionY", "getpositiony", "getY", "GetY", "gety", NULL)
		.method(&Object::GetPositionZ, "GetPositionZ", "getPositionZ", "getpositionz", "getz", "getZ", "GetZ", NULL)
		.method(&Object::GetOrientation, "GetOrientation", "getO", "geto", "GetO", NULL)
		.method(&Object::SetOrientation, "SetOrientation", "SetO", "setO", "seto", NULL)
		.method(&Object::GetSpawnX, "GetSpawnX", "getSpawnX", "getspawnx", NULL)
		.method(&Object::GetSpawnY, "GetSpawnY", "getSpawnY", "getspawny", NULL)
		.method(&Object::GetSpawnZ, "GetSpawnZ", "getSpawnZ", "getspawnz", NULL)
		.method(&Object::GetSpawnO, "GetSpawnO", "getSpawnO", "getspawno", NULL)
		//.method("GetPosition", &Object::GetPosition)
		.method((float(Object::*)(Object*))&Object::CalcDistance, "CalcDistanceToObject", "calcdinstancetoobject", NULL)
		.method((float(Object::*)(float, float, float))&Object::CalcDistance, "CalcDistanceToLocation", "calcdistancetolocation", "calcdist2location", NULL)
		.method((float(Object::*)(Object*, Object*))&Object::CalcDistance, "CalcDistanceBtwnObjects", "calcdistancebtwnobjects", NULL)
		.method((float(Object::*)(Object*, float, float, float))&Object::CalcDistance, "CalcDistanceObject2Location", "CalcDistanceObjectToLocation", "calcdistanceobject2location", NULL)
		.method((float(Object::*)(float, float, float, float, float, float))&Object::CalcDistance, "CalcDistanceLocation2Location", "CalcDistanceLocationToLocation", "calcdistancelocationtolocation", "calcdistancelocation2location", NULL)
		//.method("GetMapMgr", &Object::GetMapMgr)
		.method(&Object::GetMapId, "GetMapID", "getMapID", "getmapid", NULL)
		.method(&Object::GetZoneId, "GetZoneID", "getZoneID", "getzoneid", NULL)
		.method(&Object::SetZoneId, "SetZoneID", "setZoneID", "setzoneid", NULL)
		.method(&Object::SetMapId, "SetMapID", "setMapID", "setmapid", NULL)
		.method(&Object::GetUInt32Value, "GetUInt32Value", "getUInt32Value", "getuint32value", NULL)
		.method(&Object::GetUInt64Value, "GetUInt64Value", "getUInt64Value", "getuint64value", NULL)
		.method(&Object::SetUInt32Value, "SetUInt32Value", "setUInt32Value", "setuint32value", NULL)
		.method(&Object::SetUInt64Value, "SetUInt64Value", "setUInt64Value", "setuint64value", NULL)
		.method(&Object::GetFloatValue, "GetFloatValue", "getFloatValue", "getfloatvalue", NULL)
		.method(&Object::ModFloatValue, "ModFloatValue", "modFloatValue", "modfloatvalue", NULL)
		.method(&Object::ModFloatValueByPCT, "ModFloatValueByPCT", "modFloatValueByPCT", "modfloatvaluebypct", NULL)
		.method(&Object::ModSignedInt32Value, "ModSignedInt32Value", "modSignedInt32Value", "modsignedint32value", NULL)
		.method(&Object::ModUnsigned32Value, "ModUnsigned32Value", "modUnsigned32Value", "modunsigned32value", NULL)
		.method(&Object::GetByte, "GetByte", "getByte", "getbyte", NULL)
		.method(&Object::SetByte, "SetByte", "setByte", "setbyte", NULL)
		.method(&Object::SetByteFlag, "SetByteFlag", "setByteFlag", "setbyteflag", NULL)
		.method(&Object::RemoveByteFlag, "RemoveByteFlag", "removeByteFlag", "removebyteflag", NULL)
		.method(&Object::HasByteFlag, "HasByteFlag", "hasByteFlag", "hasbyteflag", NULL)
		.method(&Object::EventSetUInt32Value, "EventSetUInt32Value", "eventSetUInt32Value", "eventsetuint32value", NULL)
		.method(&Object::SetFloatValue, "SetFloatValue", "setFloatValue", "setfloatvalue", NULL)
		.method(&Object::SetFlag, "SetFlag", "setFlag", "setflag", NULL)
		.method(&Object::HasFlag, "HasFlag", "hasFlag", "hasflag", NULL)
		.method(&Object::isInRange, "IsInRange", "isInRange", "isinrange", NULL)
		.method(&Object::isInFront, "IsInFront", "isInFront", "isinfront", NULL)
		//.method("SetInFront", &Object::setInFront)
		.method(&Object::isInBack, "isBehind", "IsBehind", "isbehind", NULL)
		.method(&Object::isInArc, "IsInArc", "isInArc", "isinarc", NULL)
		.method(&Object::calcAngle, "calcAngle", "CalcAngle", "calcangle", NULL)
		.method(&Object::calcRadAngle, "calcRadAngle", "CalcRadAngle", "calcradangle", NULL)
		.method(&Object::getEasyAngle, "GetEasyAngle", "getEasyAngle", "geteasyangle", NULL)
		.method((const float(Object::*)(Object*))&Object::GetDistanceSq, "GetDistance2Object", "getDistance2Object", "GetDistanceToObject", "getdistancetoobject", "getdistancetobject", NULL)
		//.method("GetDistanceSq", (float(Object::*)(LocationVector&) )&Object::GetDistanceSq)
		.method((const float(Object::*)(float, float, float))&Object::GetDistanceSq, "GetDistance", "getDistance", "getdistance", NULL)
		.method(&Object::GetCurrentSpell, "GetCurrentSpell", "getCurrentSpell", "getcurrentspell", NULL)
		.method(&Object::SetCurrentSpell, "SetCurrentSpell", "setCurrentSpell", "setcurrentspell", NULL)
		.method("inrangeplayers", &Object::GetInRangePlayers)
		.method(&Object::GetInRangeOpposingFactions, "GetInRangeOpposingFactions", "getInRangeOpposingFactions", "getinrangeopposingfactions", NULL)
		.method(&Object::GetInRangeSameFactions, "GetInRangeSameFactions", "getInRangeSameFactions", "getinrangesamefactions", NULL)
		.method(&Object::GetInRangeObjects, "GetInRangeObjects", "getInRangeObjects", "getinrangeobjects", NULL)
		.method((void (Object::*)(WorldPacket*, bool, bool)) &Object::SendMessageToSet, "SendMessageToSet", "sendMessageToSet", "sendmessagetoset", NULL)
		.method(&Object::Phase, "Phase", "phase", NULL)
		.method(&Object::GetPhase, "GetPhase", "getPhase", "getphase", NULL)
		.method(&Object::IsInWorld, "IsInWorld", "isInWorld", "isinworld", NULL)
		.method(&Object::SendPacket, "SendPacket", "sendPacket", "sendpacket", NULL)
		.method((void (Object::*)(WorldPacket*, bool, bool))&Object::SendMessageToSet, "SendMessageToSet", "sendMessageToSet", "sendmessagetoset", NULL)
		.method(&Object::PlaySoundToSet, "PlaySoundToSet", "playSound", "playsound", "PlaySound", NULL)
		.method(&Object::IsInBg, "IsInBG", "isInBG", "isinbg", NULL)
		.method(&Object::DealDamage, "DealDamage", "dealDamage", "dealdamage", NULL)
		.method(&Object::PushToWorld, "PushToWorld", "pushToWorld", "pushtoworld", NULL);

		//creatable and destroyable in the lua environment.
		m	.class_<Arcemu::Gossip::Menu>("GossipMenu", true)
		.constructor< void(*)(Object*, uint32, uint32) > ()
		.method((void(Arcemu::Gossip::Menu::*)(uint8, const char*, uint32, bool))&Arcemu::Gossip::Menu::AddItem, "AddItem", "addItem", "additem", NULL)
		.method((void(Arcemu::Gossip::Menu::*)(uint8, const char*, uint32, uint32, const char*, bool))&Arcemu::Gossip::Menu::AddItem, "AddMenuItem", "addMenuItem", "fullAddItem", NULL)
		.method(&Arcemu::Gossip::Menu::Send, "Send", "send", NULL)
		.method(&Arcemu::Gossip::Menu::getLanguage, "GetLanguage", "getLanguage", "getlanguage", NULL)
		.method(&Arcemu::Gossip::Menu::setLanguage, "SetLanguage", "setLanguage", "setlanguage", NULL)
		.method(&Arcemu::Gossip::Menu::setTextID, "SetTextID", "setTextID", "settextid", NULL)
		.method(&Arcemu::Gossip::Menu::getTextID, "GetTextID", "getTextID", "gettextid", NULL)
		.static_method(&Arcemu::Gossip::Menu::Complete, "Complete", "complete", NULL)
		.static_method(&Arcemu::Gossip::Menu::SendQuickMenu, "SendQuickMenu", "sendQuickMenu", "sendquickmenu", NULL)
		.static_method(&Arcemu::Gossip::Menu::SendSimpleMenu, "SendSimpleMenu", "sendSimpleMenu", "sendsimplemenu", NULL);

		m	.subclass<DynamicObject, Object>("DynamicObject", true) //make it destroyable.
		.method(&DynamicObject::Create, "Create", "create", NULL)
		.method(&DynamicObject::Remove, "Remove", "remove", NULL);

		m	.class_< ObjectWrap<uint64 > >("uint64");
		//These are needed because 'classname<T>::name()' is how luabridge assigns the correct metatables to a type.
		m	.class_decl< ObjectWrap<uint64 &> >("uint64").class_decl< ObjectWrap<const uint64> >("uint64").class_decl< ObjectWrap<const uint64 &> >("uint64");
		m	.class_decl<uint64>("uint64").class_decl<uint64 &>("uint64").class_decl<const uint64>("uint64").class_decl<const uint64 &>("uint64");

	}
}